{*
Update logs
10/01/2010        immanuel192     Temporary remove link to Vietnamese and English switch
Sept 1, 2012 - trungdt - Improve Google Translate
Oct 20, 2012 - trungdt - List all language in hidden mode, to support more search result
*}
{* List all language switch links*}
<div style="display: none;">
 {foreach from=$langs item=lang}
    <a href="/{$lang.url_prefix}" title="{$lang.name}" alt="{$lang.name}">{$lang.name}</a>
 {/foreach}
</div>
{* End list *}

<script language="javascript">
    var _absoft_available_language = new Array();
    {foreach from=$langs item=lang}
        _absoft_available_language.push("{$lang.lang_code}");
    {/foreach}
    var _ab_current_url = "{$current_path}";
</script>


<div class="title_lang">{$_TR.language}</div>
<select onchange="google_translate(this.value);" class="sllangdropdown notranslate" name="sl" id="old_sl" tabindex="0" style="height: 20px; font-size: 10px; text-align: left;">
    <option selected="" value="">Buildin language</option>
    {foreach from=$langs item=lang}
        <option {if $smarty.const.LANG_LOCALE == $lang.locale}selected{/if} value="{$lang.lang_code}">{$lang.name}</option>
    {/foreach}
    <option value="">-----------------</option>
    <option value="">Google Translate</option>
    <option value="af">Afrikaans</option>
    <option value="sq">Albanian</option>
    <option value="ar">Arabic</option>
    <option value="be">Belarusian</option>
    <option value="bg">Bulgarian</option>
    <option value="ca">Catalan</option>
    <option value="zh-CN">Chinese</option>
    <option value="hr">Croatian</option>
    <option value="cs">Czech</option>
    <option value="da">Danish</option>
    <option value="nl">Dutch</option>
    <option value="et">Estonian</option>
    <option value="tl">Filipino</option>
    <option value="fi">Finnish</option>
    <option value="fr">French</option>
    <option value="gl">Galician</option>
    <option value="el">Greek</option>
    <option value="ht">Haitian Creole ALPHA</option>
    <option value="iw">Hebrew</option>
    <option value="hi">Hindi</option>
    <option value="hu">Hungarian</option>
    <option value="is">Icelandic</option>
    <option value="id">Indonesian</option>
    <option value="ga">Irish</option>
    <option value="ja">Japanese</option>
    <option value="ko">Korean</option>
    <option value="lv">Latvian</option>
    <option value="lt">Lithuanian</option>
    <option value="mk">Macedonian</option>
    <option value="ms">Malay</option>
    <option value="mt">Maltese</option>
    <option value="no">Norwegian</option>
    <option value="fa">Persian</option>
    <option value="pl">Polish</option>
    <option value="pt">Portuguese</option>
    <option value="ro">Romanian</option>
    <option value="sr">Serbian</option>
    <option value="sk">Slovak</option>
    <option value="sl">Slovenian</option>
    <option value="es">Spanish</option>
    <option value="sw">Swahili</option>
    <option value="sv">Swedish</option>
    <option value="th">Thai</option>
    <option value="uk">Ukrainian</option>
    <option value="vi">Vietnamese</option>
    <option value="cy">Welsh</option>
    <option value="yi">Yiddish</option>
</select>
{literal}
<script language="javascript">
    //$("select").change(displayVals);
    if(self != top) { top.location.href = top.c.location.href; }
    jQuery(document).ready(function(){
       if(self != top) { top.location.href = top.c.location.href; } 
       
       if (document.location.host == "translate.googleusercontent.com")
       {
         // we are in google translate mode
         var tl_pos = document.location.href.search("tl=");
          var tl_lang = document.location.href.substr(tl_pos + 3, 2);
          jQuery("#old_sl").val(tl_lang);
       }
    });
    function google_translate(value)
    {
        if (value == "")
            return;
            
        // before use google translate, remember to check our available language
        for (var i = 0; i< _absoft_available_language.length; i++)    
        {
            if (_absoft_available_language[i] == value)
            {
                window.location = '{/literal}{$smarty.const.URL_FULL}{literal}index.php?module=langmodule&action=changelang&lid='+value;
                return;
            }
        }
        // else, -> google tranlsate
        glink = "http://translate.google.com/translate?hl=en&sl=auto&tl="+value+"&u="+_ab_current_url;
        
        document.location = glink;
    }
</script>

{/literal}
